package foundation.deciaml_to_hexadecimal;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

/**
 * 十进制转十六进制
 */
public class Main {
    public static void main(String[] args) {
        Map<Integer, Character> map = new HashMap<>();
        map.put(10, 'A');
        map.put(11, 'B');
        map.put(12, 'C');
        map.put(13, 'D');
        map.put(14, 'E');
        map.put(15, 'F');
        Scanner scanner = new Scanner(System.in);
        int num = scanner.nextInt();
        StringBuilder str = new StringBuilder(Integer.toBinaryString(num));
        int len = str.length();
        // 如果str的长度不为4的整数倍，需要补零
        if (len % 4 != 0) {
            for (int i = 0; i < 4 - len % 4; i++) {
                str.insert(0, 0);
            }
        }
        len = str.length();
        StringBuilder stringBuilder = new StringBuilder();
        for (int i = len - 1; i >= 3; i -= 4) {
            int tmp =Character.getNumericValue(str.charAt(i - 3)) * 8
                    + Character.getNumericValue(str.charAt(i - 2)) * 4
                    + Character.getNumericValue(str.charAt(i - 1)) * 2
                    + Character.getNumericValue(str.charAt(i));
            if (tmp > 9) {
                stringBuilder.append(map.get(tmp));
            } else {
                stringBuilder.append(tmp);
            }
        }
        System.out.println(stringBuilder.reverse());
    }
}
